package com.kaifamiao.test;

import java.io.File;
import java.io.FilenameFilter;

public class RenameFile {


    public static void main(String[] args) {
        String path = "G:\\新建文件夹\\v12.5";
        rename(path);
    }

    public static void rename(String path){
        File dic = new File(path);

        File[] files = dic.listFiles();

        String replace = "【海量 资源：666java.com】";
        for (File file : files){
            if (file.isFile()){
                File parentFile = file.getParentFile();
                String name = file.getName().replace(replace, "");
                File newFile = new File(parentFile, name);

                file.renameTo(newFile);
                System.out.println(newFile);
            } else {
                rename(file.getAbsolutePath());
            }

        }
    }
}